<template>
  <div>
    <BreakSpace label="基本信息" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel
      ref="baseInfo"
      :list="initFormBase"
      :cols="3"
      :labelWidth="140"
      :isSubmitBtn="false"
      :formType="topBasicForm"
      @formChange="formChangeHandleBase"
    />

    <BreakSpace label="授权信息" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel
      ref="empowerInfo"
      :list="initFormEmpower"
      :cols="3"
      :labelWidth="140"
      :isSubmitBtn="false"
      :formType="topBasicForm"
      @formChange="formChangeHandleEmpower"
    />

    <BreakSpace label="建设节点信息" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel
      ref="buildInfo"
      :list="initFormBuild"
      :cols="3"
      :labelWidth="140"
      :isSubmitBtn="false"
      :formType="'show'"
      @formChange="formChangeHandleBuild"
    />

    <BreakSpace label="进度节点信息" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable
      height='300'
      ref="progressTable"
      :columns="progressColumns" 
      :dataSource="progressDataSource"
      :isColumnFilter="false"
      :isSelectColumn="isSelectColumn"
      :datakey="'dealerName'"
      :params="fetchParamsProgress" 
      :isToperInfo="false"
      columnsRef='origin_construct_review_addDialog_01'
      :onColumnsChange="columns => this.columns = columns"
    >
    <template slot="controls">
        <el-button size="small" v-if="infoBasicForm != 'show'" :disabled="isPass" type="primary" icon="el-icon-plus" @click="openProgress('','add')">新增</el-button>
      </template>
    </FilterTable>

    <BreakSpace label="订购节点信息" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable
      height='300'
      ref="orderTable"
      :columns="orderColumns"
      :dataSource="orderDataSource"
      :isColumnFilter="false"
      :isSelectColumn="isSelectColumn"
      :datakey="'dealerName'"
      :isToperInfo="false"
      columnsRef='origin_construct_review_addDialog_02'
      :onColumnsChange="columns => this.columns = columns"
    >
    <template slot="controls">
        <el-button size="small" v-if="infoBasicForm != 'show'" :disabled="isPass" type="primary" icon="el-icon-plus" @click="openOrder('','add')">新增</el-button>
      </template>
    </FilterTable>

    <BreakSpace label="总部反馈说明" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable
      height='150'
      ref="feedbackTable" 
      :columns="feedbackColumns"
      :dataSource="feedbackDataSource"
      :isColumnFilter="false"
      :isSelectColumn="isSelectColumn"
      :datakey="'dealerName'"
      :isToperInfo="false"
      columnsRef='origin_construct_review_addDialog_03'
      :onColumnsChange="columns => this.columns = columns"
    >
    <template slot="controls">
        <!-- <el-button size="small" v-if="infoBasicForm != 'show'" :disabled="isPass" type="primary" icon="el-icon-plus" @click="openFeedAdd('','add')">新增</el-button> -->
        <el-button size="small" type="primary" icon="el-icon-plus" @click="openFeed">查看全部反馈说明</el-button>
      </template>
    </FilterTable>

    <BreakSpace label="施工进度说明" :containerStyle="{ marginBottom: '10px' }" />
    <!-- 搜索 -->
    <TopFilter  
      :list="topFilterInit"  
      :cols="2"  
      labelWidth="100"  
      @filterChange="changeHandle"
      ></TopFilter>
    <FilterTable
      height='300'
      ref="photoTable"
      :columns="photoColumns"
      :fetchapi="fetchApiPhoto"
      :isColumnFilter="false"
      :isSelectColumn="isSelectColumn"
      :datakey="'records'"
      :params="fetchParams" 
      :isToperInfo="false"
      columnsRef='origin_construct_review_addDialog_04'
      :onColumnsChange="columns => this.columns = columns"
    >
    </FilterTable>

    <BreakSpace label="其他施工附件" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel
      ref="fileInfo"
      :list="initFormFile"
      :cols="1"
      :labelWidth="140"
      :isSubmitBtn="false"
      :formType="'show'"
      @formChange="formChangeHandleFile"
    />

    <!-- 进度节点弹窗 -->
    <BaseDialog
      title="进度节点维护"
      :visible.sync="visibleProgress"
      width="400px"
      destroyOnClose
      :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}"
    >
      <progress-modal v-model="initDataProgress" ref="addDialogProgress" @close="closeProgress" />
    </BaseDialog>
    <!-- 订购节点弹窗 -->
    <BaseDialog
      title="订购节点维护"
      :visible.sync="visibleOrder"
      width="400px"
      destroyOnClose
      :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}"
    >
      <order-modal v-model="initDataOrder" ref="addDialogOrder" @close="closeOrder" />
    </BaseDialog>
    <!-- 总部反馈信息弹窗 -->
    <BaseDialog 
      title="总部反馈信息" 
      width="700px"
      destroyOnClose
      :visible.sync="visibleFeed"
      :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}" >
      <feed-madal  v-model="initDataFeed"   ref="projectDialog" @close="closeFeed" />
    </BaseDialog>


    <div class="dialogBottmView" >
      <el-button @click="closeDialog">关闭</el-button>
      <!-- 不校验保存 -->
      <el-button @click="saveDialog" :loading="saveLoading" v-if="infoBasic != 'show' && !isCreateTempAccount" :disabled="isSave" type="primary">保存</el-button>
	    <!-- 校验保存 -->
      <el-button @click="saveCompleteDialog" :loading="saveLoading" v-if="infoBasic != 'show' && isCreateTempAccount" :disabled="isSave" type="primary">保存</el-button>

      <el-button @click="createDialog" :loading="saveLoading" v-if="infoBasic != 'show'" :disabled="isCreateTempAccount" type="primary">生成临时账号</el-button>
      <el-button @click="turnDialog" :loading="saveLoading" v-if="infoBasic != 'show'" :disabled="isChangeDealer" type="primary">转经销商</el-button>

    </div>
  </div>
</template>
<script>
import feedMadal from './oemFeedback' //总部反馈列表
import { dictionary } from '@/utils/dictMixin';
import { turnDealer,createDealer,updataDealerApply,searchDealerApplyPnode ,searchDealerApplyOnode,searchDealerApplyOemFeedback,searchDealerApplyDealerFeedback,searchOtherPhoto,delProgressById,delOrderById} from '@/api/cms-api/origin/construct/dealer';
import { getRegion, getCommunity } from '@/api/cms-common/dealerdata/index';
import { searchConstructionList } from '@/api/cms-api/origin/baseSetting/construction';
import { region } from '@/api/cms-common/region';
import * as types from '@/api/cms-api/origin/construct/dealer/types';
import progressModal from './infoScheduleModal'; //进度节点信息
import orderModal from './infoOrderModal'; //订购节点信息
import { formatdateByDay, formatdateByTime } from '@/utils/index';
import { dealerCommon,isArcfox } from '@/api/cms-api/origin/commonDealerType';		//渠道类型工具类

export default {
  components: {
    // photoMadal,
    feedMadal,
    progressModal,
    orderModal
  },
  mixins: [dictionary,dealerCommon,region],
  props: {
    value:{
        type: Object,
        default: null
    }
  },
  data() {
    return {
      applyId:"",  //经销商申请ID，进入赋值
      formData:[],
      dealerList:[],
      productList:[],
      isChangeDealer:false, //转经销商按钮是否可用
      isSubmit:false, //审批通过按钮是否可用
      isPass:false, //反馈按钮是否可用 如果已经审批通过，则反馈按钮不可用
      saveLoading: false,
      dataSource:[],
      progressDataSource:[],
      orderDataSource:[],
      feedbackDataSource:[],
      photoDataSource:[],
      initData: {}, //施工进度弹窗传递参数
      initDataProgress:{},  //进度节点弹窗传递参数
      initDataOrder:{},  //订购节点弹窗传递参数
      initDataFeed:{},  //总部反馈列表弹窗传递参数
      initDataFeedAdd:{},  //总部反馈新增弹窗传递参数
      fetchParams:{"applyId":this.value.rowData.applyId,'check':'check'},  //施工进度列表查询参数
      fetchParamsProgress:{}, //进度节点列表查询参数
      visibleProgress:false,  //进度节点 弹窗打开关闭参数
      visibleOrder:false,  //进度订购节点 弹窗打开关闭参数
      visibleFeed:false,  //总部反馈列表 弹窗打开关闭参数
      visiblePhoto:false,
      isSelectColumn: false,
      initFormBase: this.initFormBaseFun(),     //基本信息-初始化控件
      initFormEmpower: this.initFormEmpowerFun(), //授权信息-初始化控件
      initFormBuild: this.initFormBuildFun(),   //建设节点信息-初始化控件
      progressColumns: this.creatHeaderProgress(),  //进度节点信息-初始化表格头
      orderColumns: this.creatHeaderOrder(),    //订购节点信息-初始化表格头
      feedbackColumns: this.creatHeaderFeedback(),  //总部回馈-初始化表格头
      photoColumns: this.creatHeaderPhoto(),  //施工进度说明-初始化表格头
      initFormFile: this.initFormFileFun(),   //其他施工照片-初始化控件
      cityData: {},
      // infoBasicForm:this.value.type,  //是否可以编辑参数
      infoBasicForm:'show',  //是否可以编辑参数
      topBasicForm:this.value.type, // 顶部表单是否可以编辑参数
      submitType:'',  //提交类型 审核通过 pass  反馈 save 转经销商 turn
      fetchApiPhoto: searchDealerApplyDealerFeedback,
      topFilterInit:this.topFilterInitFun(),   //施工进度查询区域
      infoBasic:this.value.type,  //生成临时账号与转正式经销商按钮是否显示参数
      isSave:false, //保存按钮是否可用
      isCreateTempAccount:false, //生成临时账号按钮是否可用
      isChangeDealer:false, //转经销商按钮是否可用
    };
  },
  mounted() {
    
    this.init();
  },
  computed: {
    
  },
  created() {
    //初始化事业部下拉数据
    this.getDeptData();
    //初始化省份信息
    this.initProvince();
    //初始化项目下拉数据
    this.getConsData();
  },
  methods: {
    //修改时，初始化页面数据
    async init(){
      // 更新接口需要的记录 ID
      this.applyId = this.value.rowData.applyId;
        //初始化所在市，区
        if(this.value.rowData['provinceId']){
          this.initCity(this.value.rowData['provinceId'],false);
        }
        if(this.value.rowData['cityId']){
          this.initTown(this.value.rowData['cityId'],false);
        }
        //初始化办事处
        if(this.value.rowData['deptId']){
          this.changeDeptSelect(this.value.rowData['deptId'],false);
        }
        //初始化渠道类型
        this.changeDealerType(this.value.rowData['dealerType'],false);

        //判断状态是否为部分反馈 如果是，则【审批通过】按钮可用
        // if(this.value.rowData.status==types.BUILD_STATUS_PART_FEEDBACK){
        //   this.isSubmit = false;
        // }


        //判断是否已生成临时账号
        if(this.value.rowData.isCreateTempAccount=="10041001"){
          this.isCreateTempAccount = true;

          this.infoBasicForm='edit';
        }
        //判断是否已转经销商
        if(this.value.rowData.isChangeDealer=="10041001"){
          this.isChangeDealer = true;
          this.isCreateTempAccount = true;

          this.isSave = true;   //保存按钮不可点击
          this.topBasicForm = "show";   //基本信息、授权信息  不可编辑

          this.infoBasicForm='edit';
        }
        
        //判断是否已审批通过 如果已通过，则【审批通过】和【反馈】按钮不可用
        // if(this.value.rowData.status==types.BUILD_STATUS_PASS){
        //   this.isPass = true;
        //   this.isSubmit = true;
        // }

        //判断是否已转经销商
        // if(this.value.rowData.isChangeDealer=="10041001"){
        //   this.isChangeDealer = true;
        //   this.topBasicForm = "show";
        //   this.initFormEmpower.find(item => item.fieldName === 'tempLabour').disabled = true;
        //   this.initFormBase.find(item => item.fieldName === 'ownBrandCode').disabled = true;
        //   // this.infoBasicForm='show';
        // }

        //循环为表单赋值
        //基本信息
        this.initFormBase.forEach(x => {
          if(x.fieldName === 'ownBrandCodeList'){
            if(this.value.rowData['ownBrandCode']){
              let list = this.value.rowData['ownBrandCode'].split(',');
              x.initialValue  = list.map(x => parseInt(x));
            }else{
              x.initialValue  = [];
            }
          }else if(x.fieldName === 'createdAt'){
            if(this.value.rowData[x.fieldName]){
              x.initialValue = formatdateByDay(this.value.rowData[x.fieldName]);
            }
          }else{
            x.initialValue = this.value.rowData[x.fieldName];
          }
          if(x.fieldName=='appId'){
            //判断品牌，如果为ARCFOX时，细分类别显示且必填,渠道类型中，包含直营店、非直营店
            if(isArcfox()){
              this.dealerTypeRemove = ['25381006'];
            }else{
              this.dealerTypeRemove = ['25381004','25381005','25381006'];//2538
            }
            this.initFormBase[4].itemList = this.createDictListRemoveCodes('2538',this.dealerTypeRemove);
          }
        });
        this.initFormBase[0].initialValue=this.value.rowData.appId.toUpperCase();
        //授权信息
        this.initFormEmpower.forEach(x => {
          x.initialValue = this.value.rowData[x.fieldName];
        });
        //建设节点信息 
        this.initFormBuild.forEach(x => {
          if(x.fieldName=="agreementOpenTime"||x.fieldName=="actualOpenTime"
              ||x.fieldName=="agreementFinishTime"||x.fieldName=="actualFinishTime"){
                if(this.value.rowData[x.fieldName]){
                  x.initialValue =   formatdateByTime(this.value.rowData[x.fieldName]);
                }
          }else{
            x.initialValue =  this.value.rowData[x.fieldName];
            
          }
          
        });

      //如果已经转经销商，则设置页面字段不可填写   
      if(this.isChangeDealer){
          this.initFormBase.find(item => item.fieldName === 'ownBrandCodeList').disabled = true;
          this.initFormBase.find(item => item.fieldName === 'salesLevel').disabled = true;
          this.initFormBase.find(item => item.fieldName === 'serviceLevel').disabled = true;
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').disabled = true;
          this.initFormBase.find(item => item.fieldName === 'projectDesigner').disabled = true;
          this.initFormBase.find(item => item.fieldName === 'designerPhone').disabled = true;
      }


      //如果为明细页面(或者已经审批通过) 设置为不可编辑
      if(this.infoBasicForm == 'show'||this.isPass){
        //进度节点去掉操作列
        let columnActionIndexProgress = null;
        this.progressColumns.forEach((x,index) =>{
          if(x.dataIndex === 'column-action'){
            columnActionIndexProgress = index;
          }
        });
        if(columnActionIndexProgress != null){
          this.progressColumns.splice(columnActionIndexProgress,1);
        }
        //订购节点去掉操作列
        let columnActionIndexOrder = null;
        this.orderColumns.forEach((x,index) =>{
          if(x.dataIndex === 'column-action'){
            columnActionIndexOrder = index;
          }
        });
        if(columnActionIndexOrder != null){
          this.orderColumns.splice(columnActionIndexOrder,1);
        }
        //总部反馈去掉操作列
        let columnActionIndexFeedback = null;
        this.feedbackColumns.forEach((x,index) =>{
          if(x.dataIndex === 'column-action'){
            columnActionIndexFeedback = index;
          }
        });
        if(columnActionIndexFeedback != null){
          this.feedbackColumns.splice(columnActionIndexFeedback,1);
        }

        //施工进度去掉列表中的编辑项
        if(this.isPass){
          this.photoColumns.forEach((x,index) =>{
            x.editable=false;
          }); 
        }

      }


      //执行进度节点信息查询
      this.doSearchDealerApplyPnode();
      
      //订购节点信息
      this.doSearchDealerApplyOnode();
      
      //总部反馈信息
      this.doSearchDealerApplyOemFeedback();
      
      
      //查询其他施工照片
      let resop = await searchOtherPhoto({},this.applyId);
      if (resop.resultCode === 200) {
          this.initFormFile.forEach(x => {
            let urlsList = resop.data.urls;
            if(urlsList!=null && urlsList.length>0){
              let fileList = [];
              for(let i in urlsList){
                  let fileName = { name: urlsList[i].fileName };
                  let fileId = { url: urlsList[i].fileId };
                  let f = Object.assign(fileName, fileId);
                  fileList.push(f);
              }
              x.initialValue = fileList;
            }
          });

      }else {
        this.$notify.error({title: '提示信息',message:'获取其他施工照片信息失败!'});
      }
      
    },

    //执行进度节点信息查询
    async doSearchDealerApplyPnode(){
      //进度节点信息
      let resp = await searchDealerApplyPnode({"currentPage":0,"pageSize":1000,"applyId":this.applyId});
      if (resp.resultCode === 200) {
        this.progressDataSource = [];
        this.progressDataSource = resp.data.records;
      }else {
        this.$notify.error({title: '提示信息',message:'获取进度节点信息失败!'});
      }
    },

    //订购节点信息
    async doSearchDealerApplyOnode(){
      let reso = await searchDealerApplyOnode({"currentPage":0,"pageSize":1000,"applyId":this.applyId});
      if (reso.resultCode === 200) {
        this.orderDataSource = [];
        this.orderDataSource = reso.data.records;
      }else {
        this.$notify.error({title: '提示信息',message:'获取订购节点信息失败!'});
      }
    },
    //总部反馈信息
    async doSearchDealerApplyOemFeedback(){
      let resf = await searchDealerApplyOemFeedback({"currentPage":0,"pageSize":2,"applyId":this.applyId});
      if (resf.resultCode === 200) {
        this.feedbackDataSource=[];
        this.feedbackDataSource=resf.data.records;
      }else {
        this.$notify.error({title: '提示信息',message:'获取总部反馈信息失败!'});
      }
    },
   
    //基本信息数据
    initFormBaseFun() {
      return [
         {//0
          type: 'INPUT',
          label: '品牌',
          fieldName: 'brandIdTmp',
          // fieldName: 'appId',
          placeholder: '请输入',
          initialValue: '',
          disabled:true
        },
        {//1
          type: 'INPUT',
          label: '经销商简称',
          fieldName: 'dealerShortname',
          placeholder: '请输入',
          initialValue: '',
          maxlength:90,
          rules: isArcfox() ?
          [
            {
              required: true,
              message: '必填',
              trigger: 'blur'
            },
            { max: 15,
              message: '长度最大15字符',
              trigger: 'blur'
            }
          ]:
          [
            {
              required: true,
              message: '必填',
              trigger: 'blur'
            },
            { max: 8,
              message: '长度最大8字符',
              trigger: 'blur'
            }
          ]
        },
        {//2
          type: 'INPUT',
          label: '临时代码',
          fieldName: 'dealerCode',
          placeholder: '',
          initialValue: '系统自动生成',
          // readonly : true,
          disabled:true,
          
        },
        {//3
          type: 'INPUT',
          label: '公司全称',
          fieldName: 'dealerName',
          placeholder: '请输入',
          initialValue: '',
          selfCols:3,
          maxlength:300,
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            },
            { max: 300, 
              message: '长度最大300字符', 
              trigger: 'change' 
            }
          ]
        },
        {//4
          type: 'SELECT',
          label: '渠道类型',
          fieldName: 'dealerType',
          placeholder: '请选择',
          initialValue: '',
          itemList: this.createDictListRemoveCodes('2538',['25381004','25381005','25381006']),
          change: val => {
            this.changeDealerType(val);
          },
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        // { //5
        //   type: 'SELECT', 
        //   label: '细分类别', 
        //   fieldName: 'subType', 
        //   placeholder: '请选择', 
        //   initialValue: '', 
        //   hidden: !isArcfox() ,
        //   itemList: this.createDictList('2539'),
				// 		rules: isArcfox() ?[{required: true,message: '必填',trigger: 'change'}]:[]
				// },
        {//6
          type: 'SELECT',
          label: '经销商级别',
          fieldName: 'shopLevel',
          placeholder: '请选择',
          initialValue: '',
          hidden:false,
          itemList: this.createDictList('2540'),
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {//7
          type: 'SELECT',
          label: '事业部',
          fieldName: 'deptId',
          placeholder: '请选择',
          initialValue: '',
          itemList: [],
          change: val => {
            this.changeDeptSelect(val);
          },
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {//8
          type: 'SELECT',
          label: '办事处',
          fieldName: 'officeId',
          placeholder: '请选择',
          initialValue: '',
          itemList: [],
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {//9
          type: 'SELECT',
          label: '建设类型',
          fieldName: 'constructType',
          placeholder: '请选择',
          initialValue: '',
          itemList: this.createDictList('2541'),
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {//10
          type: 'SELECT',
          label: '省份',
          fieldName: 'provinceId',
          placeholder: '请选择',
          initialValue: "",
          change: (value) => {
            this.initCity(value)
          },
          itemList:  [],
          rules: [{
            required: true,
            message: '必填',
            trigger: 'blur'
          }]
        },
        {//11
          type: 'SELECT',
          label: '城市',
          fieldName: 'cityId',
          placeholder: '请选择',
          initialValue: "",
          itemList: [],
          change: (value) => {
            this.initTown(value)
          },
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {//12
          type: 'SELECT',
          label: '县区',
          fieldName: 'districtId',
          placeholder: '请选择',
          initialValue: "",
          itemList:  [],
          change: (value) => {
            this.initDistrict(value)
          },
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {//22
          type: 'INPUT',
          label: '建设地址',
          fieldName: 'constructAddress',
          placeholder: '请输入',
          initialValue: '',
          maxlength:300,
          selfCols:3,
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            },
            { max: 300, 
              message: '长度最大300字符', 
              trigger: 'change' 
            }
          ]
        },
        {//13
          type: 'INPUT',
          label: '店端主要联系人',
          fieldName: 'dealerLinkman',
          placeholder: '请输入',
          initialValue: '',
          maxlength:100,
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            },
            { max: 100, 
              message: '长度最大100字符', 
              trigger: 'change' 
            }
          ]
        },
        {//14
          type: 'INPUT',
          label: '联系人电话',
          fieldName: 'dealerPhone',
          placeholder: '请输入',
          initialValue: '',
          maxlength:11,
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            },
            { 
              pattern: /^[1][3,4,5,7,8][0-9]{9}$/, 
              message: '请填写正确的手机格式', 
              trigger: 'change' 
            }
          ]
        },
        {//15
          type: 'INPUT',
          label: '店端联系人邮箱',
          fieldName: 'dealerEmail',
          placeholder: '请输入',
          initialValue: '',
          maxlength:60,
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            },
            { max: 60, 
              message: '长度最大60字符', 
              trigger: 'change' 
            },
            {
              type:'email',
              message: '请输入正确的邮箱', 
              trigger: 'change' 
            }
          ]
        },
        {//16
          type: 'INPUT',
          label: '厂家负责人',
          fieldName: 'oemLinkman',
          placeholder: '请输入',
          initialValue: '',
          maxlength:100,
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            },
            { max: 100, 
              message: '长度最大100字符', 
              trigger: 'change' 
            }
          ]
        },
        {//17
          type: 'INPUT',
          label: '负责人电话',
          fieldName: 'oemPhone',
          placeholder: '请输入',
          initialValue: '',
          maxlength:11,
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            },
            { 
              pattern: /^[1][3,4,5,7,8][0-9]{9}$/, 
              message: '请填写正确的手机格式', 
              trigger: 'change' 
            }
          ]
        },
        { type: 'MULTIPLE_SELECT', 
          label: '体系内品牌', 
          fieldName: 'ownBrandCodeList', 
          placeholder: '请选择', 
          initialValue: [], 
          itemList: this.createDictList('2545')
        },
        
        {//19
          type: 'INPUT',
          label: '项目设计师',
          fieldName: 'projectDesigner',
          placeholder: '请输入',
          initialValue: '',
          disabled:false,
          maxlength:100,
          
        },
        {//20
          type: 'INPUT',
          label: '设计师电话',
          fieldName: 'designerPhone',
          placeholder: '请输入',
          initialValue: '',
          maxlength:11,
          disabled:false,
          rules: [
            { 
              pattern: /^[1][3,4,5,7,8][0-9]{9}$/, 
              message: '请填写正确的手机格式', 
              trigger: 'change' 
            }
          ]
        },
        {//21
          type: 'SELECT',
          label: '售后级别',
          fieldName: 'serviceLevel',
          placeholder: '请选择',
          initialValue: '',
          hidden:false,
          itemList: this.createDictList('2543')
        },
        
        {//18
          type: 'SELECT',
          label: '展厅级别',
          fieldName: 'salesLevel',
          placeholder: '请选择',
          initialValue: '',
          hidden:false,
          itemList: this.createDictList('2542')
        },
        {
          type: 'INPUT',
          label: '创建人',
          fieldName: 'createdByName',
          placeholder: '',
          initialValue: '',
          disabled:true,
        },
        {
          type: 'INPUT',
          label: '创建时间',
          fieldName: 'createdAt',
          placeholder: '',
          initialValue: '',
          disabled:true,
        },
        
      ];
    },
    //授权信息数据
    initFormEmpowerFun() {
      return [
         {
          type: 'SELECT',
          label: '是否边建边销',
          fieldName: 'isSaling',
          placeholder: '请选择',
          initialValue: '',
          hidden:false,
          itemList: this.createDictList('1004'),
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {
          type: 'SELECT',
          label: '是否边建边修',
          fieldName: 'isServicing',
          placeholder: '请选择',
          initialValue: '',
          hidden:false,
          itemList: this.createDictList('1004'),
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        // {
        //   type: 'INPUT_NUMBER',
        //   label: '临时工时',
        //   fieldName: 'tempLabour',
        //   placeholder: '请输入',
        //   initialValue: 0,
        //   precision:2,
        //   max:9999.99
        // },
        {type:'INPUT',label:'临时工时系数',fieldName:'tempLabour',initialValue:'',placeholder: '请输入',maxlength:4,hidden:false,
            unitRender:() => {
               return<span>%</span>
            },
            change: val => {
               utils.toNumber(this.initFormEmpower,"tempLabour",val);
            },
         }
        
      ];
    },
    //建设节点信息数据
    initFormBuildFun() {
      return [
        {
          type: 'DATE',
          label: '协议开工时间',
          fieldName: 'agreementOpenTime',
          valueFormat: 'yyyy-MM-dd', //返回数据格式
          initialValue: '',
          placeholder: '',
          style: { width: '100%' },
          
        },
        {
          type: 'DATE',
          label: '实际开工时间',
          fieldName: 'actualOpenTime',
          valueFormat: 'yyyy-MM-dd', //返回数据格式
          initialValue: '',
          placeholder: '',
          style: { width: '100%' },
          
        },
        {
          type: 'DATE',
          label: '协议完工时间',
          fieldName: 'agreementFinishTime',
          valueFormat: 'yyyy-MM-dd', //返回数据格式
          initialValue: '',
          placeholder: '',
          style: { width: '100%' },
          
        },
        {
          type: 'SELECT',
          label: '建设状态节点',
          fieldName: 'buildStatus',
          placeholder: '',
          initialValue: '',
          itemList: this.createDictList('2546'),
          
        },
        {
          type: 'INPUT',
          label: '总体建设进度',
          fieldName: 'buildProcess',
          initialValue: '',
          placeholder: '',
          unitRender: () => {
            return <el-button slot="append">%</el-button>;
          },
          
        },
        {
          type: 'DATE',
          label: '实际完工时间',
          fieldName: 'actualFinishTime',
          style: { width: '100%' },
          valueFormat: 'yyyy-MM-dd', //返回数据格式
          initialValue: '',
          placeholder: '',
        }
      ];
    },

    //进度节点列表表头
    creatHeaderProgress() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.$index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 100,
          fixed: 'left',
          render: (props, h) => {
            return (
              <div>
                <el-button size="mini" v-if="infoBasicForm != 'show'" type="text" onClick={() => this.openProgress(props.row,'edit')}>
                  编辑
                </el-button>
               <el-button size="mini" v-if="infoBasicForm != 'show'" type="text" onClick={() => this.delProgress(props.row)}>删除</el-button>
              </div>
            );
          }
        },
        {
          title: '进度节点类型',
          dataIndex: 'nodeType',
          sorter: true,
          render: props => {
            //编码转汉字
            return <span>{this.createDictText(props.row.nodeType, '2547')}</span>;
          }
        },
        { title: '时间', dataIndex: 'nodeTime', dateFormat:'yyyy-MM-dd',sorter: true },
        {
          title: '附件',
          dataIndex: 'urls',
          sorter: true,
          render: props => {
            let fileStr=[];
            for(let i in props.row.urls){
              fileStr.push(<a href={props.row.urls[i].fileId} style='color:blue' target="_blank">{props.row.urls[i].fileName}</a>);
                // fileStr.push(
                //   <el-popover
                //   width="140"
                //   trigger="click"
                //   >
                //   <el-image  style="width: 140px; height: 140px" 
                //    src={props.row.urls[i].fileId}  
                //    preview-src-list={[props.row.urls[i].fileId]} 
                //    onClick={() => this.imgLick(props.row.urls[i])}></el-image>
                //   <el-button slot="reference" type="text" >{props.row.urls[i].fileName}</el-button>
                // </el-popover>
                  
                //   );
            }
            return <span>{fileStr}</span>;
          }
        }
      ];
    },

    //订购节点列表表头
    creatHeaderOrder() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.$index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 100,
          fixed: 'left',
          render: (props, h) => {
            return (
              <div>
                <el-button size="mini" v-if="infoBasicForm != 'show'" type="text" onClick={() => this.openOrder(props.row,'edit')}>
                  编辑
                </el-button>
               <el-button size="mini" v-if="infoBasicForm != 'show'" type="text" onClick={() => this.delOrder(props.row)}>删除</el-button>
              </div>
            );
          }
        },
        { title: '订购节点类型', dataIndex: 'onodeType', sorter: true ,
           render: props => {    //编码转汉字
            return <span>{this.createDictText(props.row.onodeType, '2548')}</span>;
        }},
        { title: '订购时间', dataIndex: 'orderTime',dateFormat:'yyyy-MM-dd', sorter: true },
        { title: '到货时间', dataIndex: 'arrivalTime',dateFormat:'yyyy-MM-dd', sorter: true},
        { title: '订购金额', dataIndex: 'orderFee',numberFormat:true,  sorter: true,
          // render: props => {    
          //   if(props.row.orderFee==null){
          //     return '';
          //   }else{
          //     return props.row.orderFee;
          //   }
          // }
        },
        { title: '安装时间', dataIndex: 'installTime',dateFormat:'yyyy-MM-dd', sorter: true}
      ];
    },
    //总部反馈列表表头
    creatHeaderFeedback () {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.$index + 1}</span>;
          }
        },
       
        { title: '执行反馈状态', dataIndex: 'feedbackStatus', sorter: true ,
           render: props => {    //编码转汉字
            return <span>{this.createDictText(props.row.feedbackStatus, '2549')}</span>;
        }},
        { title: '周度', dataIndex: 'feedbackWeek', sorter: true ,
           render: props => {    //编码转汉字
            return <span>{this.createDictText(props.row.feedbackWeek, '2576')}</span>;
        }},
        { title: '时间', dataIndex: 'feedbackTime',dateFormat:'yyyy-MM-dd', sorter: true},
        { title: '进度说明', dataIndex: 'processDesc', sorter: true},
        { title: '整改项目', dataIndex: 'reformItem', sorter: true}
      ];
    },
    //施工进度说明列表表头
    creatHeaderPhoto() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '项目', dataIndex: 'constructionNamePra', sorter: true },
        { title: '子项目', dataIndex: 'constructionName', sorter: true },
        { title: '附件', dataIndex: 'urls', 
          render: props => {
            let fileStr=[];
            for(let i in props.row.urls){
              fileStr.push(<a href={props.row.urls[i].fileId} style='color:blue' target="_blank">{props.row.urls[i].fileName}</a>);
                // fileStr.push(
                //   <el-popover
                //   width="140"
                //   trigger="click"
                //   >
                //   <el-image  style="width: 140px; height: 140px" 
                //    src={props.row.urls[i].fileId}  
                //    preview-src-list={[props.row.urls[i].fileId]} 
                //    onClick={() => this.imgLick(props.row.urls[i])}></el-image>
                //   <el-button slot="reference" type="text" >{props.row.urls[i].fileName}</el-button>
                // </el-popover>
                  
                //   );
            }
            return <span>{fileStr}</span>;
          }
        },
        { title: '上传日期', dataIndex: 'updatedAt', sorter: true,dateFormat:'yyyy-MM-dd', },
        { title: '审核结果', dataIndex: 'auditResult', sorter: true ,
           render: props => {    //编码转汉字
            return <span>{this.createDictText(props.row.auditResult, '2550')}</span>;
        }},
        { title: '审核说明', dataIndex: 'auditDesc',  sorter: true  }
      ];
    },
    //附件信息数据
    initFormFileFun() {
      return [
        {
          type: 'UPLOAD_FILE',
          label: '其他施工附件',
          fieldName: 'fileUrl',
          initialValue: '',
          disabled:true,
          upload: {
            limit:0,
            actionUrl: '/api/file/oss/upload',
          }
        }
      ];
    },
    //获取事业部下拉列表数据
    async getDeptData() {
      const res = await this._$getNotBigcustomerData();
      //if (res.resultCode === 200) {
        //this.initFormBase.find(item => item.fieldName === 'deptId').itemList = res.data.map(x => ({ value: parseInt(x.id), text: x.orgName }));
      //}
      this.initFormBase.find(item => item.fieldName === 'deptId').itemList = res;
    },
    
    //事业部下拉改变执行方法，级联查询该事业部下的办事处
    async changeDeptSelect(deptId,flag = true) {
      if(flag){
        this.initFormBase.find(item => item.fieldName === 'officeId').initialValue = '';
        this.initFormBase.find(item => item.fieldName === 'officeId').itemList = [];
      }
      if (!deptId) {
      } else {
        const res = await getCommunity(deptId);
        if (res.resultCode === 200) {
          this.initFormBase.find(item => item.fieldName === 'officeId').itemList = res.data.map(x => ({ value: parseInt(x.id), text: x.orgName }));
        }
      }
    },
    
    //初始化所在省份
    async initProvince(){
      let pl = this.createRegionList();
      this.initFormBase.find(item => item.fieldName === 'provinceId').itemList = pl;
    },
    //初始化所在省份
    async initProvince(){
      let pl = this.createRegionList();
      this.initFormBase.find(item => item.fieldName === 'provinceId').itemList = pl;
      // this.initFormBase[19].itemList = pl;
    },
    //初始化所在市数据
    async initCity(provinceId,flag = true){
      if(flag){
        //清空市
        this.initFormBase.find(item => item.fieldName === 'cityId').initialValue="";
        this.initFormBase.find(item => item.fieldName === 'cityId').itemList = [];
        //清空县
        this.initFormBase.find(item => item.fieldName === 'districtId').initialValue="";
        this.initFormBase.find(item => item.fieldName === 'districtId').itemList=[];
        //动态填入建设地址
        if(provinceId){
          this.initFormBase.find(item => item.fieldName === 'constructAddress').initialValue = this.createRegionText(provinceId);
        }else{
          this.initFormBase.find(item => item.fieldName === 'constructAddress').initialValue = "";
        }
      }

      if(!provinceId || provinceId==null || typeof(provinceId)=='undefined'){
        return;
      }
      //取省数据
      let rd = this.getRegionData();
      this.cityData = rd[provinceId].children;
      let cl = this.createSubRegionList(this.cityData);
      this.initFormBase.find(item => item.fieldName === 'cityId').itemList = cl;
    },
    //初始化所在县数据
    async initTown(cityId,flag = true){
      if(flag){
        //清空县
        this.initFormBase.find(item => item.fieldName === 'districtId').initialValue="";
        this.initFormBase.find(item => item.fieldName === 'districtId').itemList=[];
        //动态填入建设地址
        if(cityId){ //如果所选的市不为空
          this.initFormBase.find(item => item.fieldName === 'constructAddress').initialValue =this.createRegionText(this.initFormBase.find(item => item.fieldName === 'provinceId').initialValue) + this.createRegionText(cityId);
        }else{  //如果所选的市为空
          if(this.initFormBase.find(item => item.fieldName === 'provinceId').initialValue){ //如果所选的省不为空
            this.initFormBase.find(item => item.fieldName === 'constructAddress').initialValue =this.createRegionText(this.initFormBase.find(item => item.fieldName === 'provinceId').initialValue);
          }else{
            this.initFormBase.find(item => item.fieldName === 'constructAddress').initialValue = "";
          }
        }
      }
      if(!cityId || cityId==null || typeof(cityId)=='undefined'){
        return;
      }
      let td = this.cityData[cityId].children;
      let tl = this.createSubRegionList(td);
      this.initFormBase.find(item => item.fieldName === 'districtId').itemList = tl;
    },
    initDistrict(districtId){
      //动态填入建设地址
      if(districtId){ //如果所选的县不为空
        this.initFormBase.find(item => item.fieldName === 'constructAddress').initialValue =this.createRegionText(this.initFormBase.find(item => item.fieldName === 'provinceId').initialValue) + this.createRegionText(this.initFormBase.find(item => item.fieldName === 'cityId').initialValue) + this.createRegionText(districtId);
      }else{  //如果所选的县为空
        if(this.createRegionText(this.initFormBase.find(item => item.fieldName === 'cityId').initialValue)){ //如果所选的市不为空
          this.initFormBase.find(item => item.fieldName === 'constructAddress').initialValue =this.createRegionText(this.initFormBase.find(item => item.fieldName === 'provinceId').initialValue) + this.createRegionText(this.initFormBase.find(item => item.fieldName === 'cityId').initialValue);
        }else{  //如果所选的市为空
          if(this.initFormBase.find(item => item.fieldName === 'provinceId').initialValue){ //如果所选的省不为空
            this.initFormBase.find(item => item.fieldName === 'constructAddress').initialValue =this.createRegionText(this.initFormBase.find(item => item.fieldName === 'provinceId').initialValue);
          }else{  //如果所选的省为空
            this.initFormBase.find(item => item.fieldName === 'constructAddress').initialValue = "";
          }
        }
      }
        
    },
    //渠道类型切换
    changeDealerType(type,flag=true) {
      if (type) {
        //如果为4s店 展厅级别和售后级别都显示 经销商级别显示
        if(type === types.DEALER_TYPE_4S){
          this.$nextTick(() =>{
            if(flag){
              this.initFormBase.find(item => item.fieldName === 'salesLevel').initialValue = undefined;
              this.initFormBase.find(item => item.fieldName === 'serviceLevel').initialValue = undefined;
              this.initFormBase.find(item => item.fieldName === 'shopLevel').initialValue = undefined;
            }
            this.initFormBase.find(item => item.fieldName === 'salesLevel').hidden = false;
            this.initFormBase.find(item => item.fieldName === 'serviceLevel').hidden = false;
            this.initFormBase.find(item => item.fieldName === 'shopLevel').hidden = false;
          } )
          //是否边建边销和是否边建边修显示并必填
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').hidden = false;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').hidden = false;
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').initialValue = '';
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').hidden = false;


        //如果为单一销售 展厅级别显示，售后级别隐藏  经销商级别显示
        }else if(type === types.DEALER_TYPE_SINGLE_SALE){
          this.$nextTick(() =>{
            if(flag){
              this.initFormBase.find(item => item.fieldName === 'salesLevel').initialValue = undefined;
              this.initFormBase.find(item => item.fieldName === 'serviceLevel').initialValue = undefined;
              this.initFormBase.find(item => item.fieldName === 'shopLevel').initialValue = undefined;
            }
            this.initFormBase.find(item => item.fieldName === 'salesLevel').hidden = false;
            this.initFormBase.find(item => item.fieldName === 'serviceLevel').hidden = true;
            this.initFormBase.find(item => item.fieldName === 'shopLevel').hidden = false;
          } )
          //是否边建边销显示并必填 ,是否边建边修不显示 临时工时不显示
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').hidden = false;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').hidden = true;
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').initialValue = '';
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').hidden = true;


        //如果为单一售后  售后级别显示，展厅级别隐藏 经销商级别显示
        }else if(type === types.DEALER_TYPE_SINGLE_AFTER){
          this.$nextTick(() =>{
            if(flag){
              this.initFormBase.find(item => item.fieldName === 'salesLevel').initialValue = undefined;
              this.initFormBase.find(item => item.fieldName === 'serviceLevel').initialValue = undefined;
              this.initFormBase.find(item => item.fieldName === 'shopLevel').initialValue = undefined;
            }
            this.initFormBase.find(item => item.fieldName === 'salesLevel').hidden = true;
            this.initFormBase.find(item => item.fieldName === 'serviceLevel').hidden = false;
            this.initFormBase.find(item => item.fieldName === 'shopLevel').hidden = false;
          } )
          //是否边建边销不显示 ,是否边建边修显示并必填
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').hidden = true;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').hidden = false;
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').initialValue = '';
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').hidden = false;

        //如果为SPACE和RACE  经销商级别、展厅级别、售后级别字段不显示
        }else if(type === types.DEALER_TYPE_DIRECT_SHOP || type === types.DEALER_TYPE_NOT_DIRECT_SHOP){
          this.$nextTick(() =>{
            if(flag){
              this.initFormBase.find(item => item.fieldName === 'salesLevel').initialValue = undefined;
              this.initFormBase.find(item => item.fieldName === 'serviceLevel').initialValue = undefined;
              this.initFormBase.find(item => item.fieldName === 'shopLevel').initialValue = undefined;
            }
            this.initFormBase.find(item => item.fieldName === 'salesLevel').hidden = true;
            this.initFormBase.find(item => item.fieldName === 'serviceLevel').hidden = true;
            this.initFormBase.find(item => item.fieldName === 'shopLevel').hidden = true;
          } )
          //边建边销要保留,是否边建边修、临时工时隐藏
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').hidden = false;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').hidden = true;
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').initialValue = '';
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').hidden = true;

        }
      }
    },
    // 基础信息表单数据获取  
    formChangeHandleBase(data){
      this.formData.base = Object.assign({},data);

      this.formData.base.ownBrandCode = data.ownBrandCodeList.join(",");
      this.$refs.empowerInfo.SUBMIT_FORM();
    },
    // 授权信息表单数据获取
    formChangeHandleEmpower(data){
      this.formData.empower = data;
      //创建临时账号
      if(this.submitType == 'create'){
        this.doCreateDialog();
      }else if(this.submitType == 'turn'){  //转正式经销商
        this.doTurnDialog();
      }else if(this.submitType === 'completeSave'){//如果是已经创建临时账号后，则需要必填的保存
        this.doCompleteSaveDialog();
	    }
    },
    //建设节点信息表单数据获取  
    formChangeHandleBuild(data){
      this.formData.build = data;
      // this.doSave();
    },

    //其他施工菜单
    formChangeHandleFile(data){
      this.formData.file = data;
    },
    
    //取消操作
    closeDialog(type) {
      this.$emit('close', { visible: false,type:type});
    },
    // 进度节点 打开窗口 -传数据
    openProgress(row,type) {
      const pram = {
        type: type,
        rowData: row,
        applyId: this.applyId
      };
      this.initDataProgress=pram;

      this.visibleProgress = true;
    },
    // 进度节点 关闭窗口 -返回数据
    closeProgress(data) {
      this.visibleProgress = data.visible; //关闭弹窗

      if (data.type === 'refresh') {
        // 刷新列表数据
        this.doSearchDealerApplyPnode();
      }
    },
    // 进度节点 -删除
    delProgress(row) {
      this.$confirm('是否确定删除?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(async() => {
          
          let res = await delProgressById(row.applyPnodeId);
          if (res.resultCode === 200) {
            this.$notify.success({title: '提示信息',message:'删除成功!'});
            // 刷新列表数据
            this.doSearchDealerApplyPnode();
          }else {
            this.$notify.error({title: '提示信息',message:res.errMsg||'删除失败!'});
          }
          
				}).catch(() => {});
    },
    // 订购节点 打开窗口 -传数据
    openOrder(row,type) {
      const pram = {
        type: type,
        rowData: row,
        applyId: this.applyId
      };
      this.initDataOrder=pram;
      this.visibleOrder = true;
    },
    // 订购节点 关闭窗口 -返回数据
    closeOrder(data) {
      this.visibleOrder = data.visible; //关闭弹窗
      if(data&&data.type&&data.type=="refresh"){
        //订购节点信息 刷新
        this.doSearchDealerApplyOnode();
      }
      
    },
    // 订购节点 删除
    delOrder(row,type) {
      this.$confirm('是否确定删除?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(async() => {
          
          let res = await delOrderById(row.applyOnodeId);
          if (res.resultCode === 200) {
            this.$notify.success({title: '提示信息',message:'删除成功!'});
            // 刷新列表数据
            this.doSearchDealerApplyOnode();
          }else {
            this.$notify.error({title: '提示信息',message:res.errMsg||'删除失败!'});
          }
          
				}).catch(() => {});
    },
    // 总部反馈列表 打开窗口 -传数据
    openFeed() {
      const pram = {
        applyId: this.applyId
      };
      this.initDataFeed=pram;
      this.visibleFeed = true;
    },
    // 总部反馈列表 关闭窗口 -返回数据
    closeFeed(data) {
      this.visibleFeed = data.visible; //关闭弹窗
    },
    //施工进度-搜索数据
    topFilterInitFun(){
      return [
          { type: 'SELECT',   
            label: '项目',    
            fieldName: 'constructionIdPra',  
            placeholder: '请输入',
            itemList: [],
            change: val => {
              this.changeConsSelect(val);
            }
          },
          { type: 'SELECT',   
            label: '子项目',    
            fieldName: 'constructionId',  
            placeholder: '请输入',
            itemList: [],
          },
          { type: 'SELECT',   
            label: '审核结果',    
            fieldName: 'auditResult',  
            placeholder: '请输入',
            itemList: this.createDictListRemoveCodes('2550',['25501001'])
          },
          { type: 'RANGE_DATE',  
            label: '上传日期',  
            fieldName: 'createdAt',  
            valueFormat: 'yyyy-MM-dd HH:mm:dd',
            placeholder: '请选择' },
            
      ]
    },
    //施工进度-搜索获取数据
    changeHandle(val){
      if (!val) {
        val = {createdAt:[]}
      }
      this.fetchParams = Object.assign({"applyId":this.value.rowData.applyId,
        createdAtStart:val.createdAt[0]||undefined,
        createdAtEnd:val.createdAt[1]||undefined,
        check:'check'
      }, val);
    },
    //获取项目下拉列表数据
    async getConsData() {
      const res = await searchConstructionList();
      if (res.resultCode === 200) {
        this.topFilterInit[0].itemList = res.data.map(x => ({ value: parseInt(x.constructionId), text: x.constructionName }));
      }
    },
    
    //项目下拉改变执行方法，级联查询该项目下的子项目
    async changeConsSelect(consId) {
      this.topFilterInit[1].initialValue = '';
      this.topFilterInit[1].itemList = [];
      if (consId) {
        const res = await searchConstructionList({"parConstructionId":consId});
        if (res.resultCode === 200) {
          this.topFilterInit[1].itemList = res.data.map(x => ({ value: parseInt(x.constructionId), text: x.constructionName }));
        }
      }
    },

    //保存
    async saveDialog(){
      this.saveLoading = true;
      this.$refs.baseInfo.excuteFormData(this.$refs.baseInfo.form);
      let base = Object.assign({},this.$refs.baseInfo.form);
      if(base.ownBrandCodeList){
        base.ownBrandCode = base.ownBrandCodeList.join(",");
      }
      this.$refs.empowerInfo.excuteFormData(this.$refs.empowerInfo.form);
      let empower = this.$refs.empowerInfo.form;

      let submitData = Object.assign({},this.value.rowData,base,empower);
      console.log("submitData======",submitData);
      let res;
      //如果传入参数不为空并且为修改
      if(this.value!=null && this.value.type=="edit"){
        res = await updataDealerApply(submitData,this.applyId);
      }else{
        res = await insertDealerApply(submitData);
      }
      if (res.resultCode === 200) {
        this.$notify.success({title: '提示信息',message:'保存成功!'});
        // 重新加载
        this.closeDialog('refresh');
      }else {
        this.$notify.error({title: '提示信息',message:res.errMsg||'保存失败!'});
        this.saveLoading = false;
        //this.closeDialog();
      }

    },
    async saveCompleteDialog(){
      this.submitType = 'completeSave';
      this.$refs.baseInfo.SUBMIT_FORM();
    },
    //生成临时账号
    createDialog(){
      this.submitType = 'create';
      this.$refs.baseInfo.SUBMIT_FORM();
    },
    //转经销商
    turnDialog(){
      this.submitType = 'turn';
      this.$refs.baseInfo.SUBMIT_FORM();
    },
     //执行生成临时账号
    async doCreateDialog(){
        this.saveLoading = true;
        let submitData = Object.assign({},this.value.rowData,this.formData.base,this.formData.empower);
        console.log("submitData:",submitData);
        let res;

        res = await createDealer(submitData,this.applyId);
        if (res.resultCode === 200) {
          this.$notify.success({title: '提示信息',message:'生成临时账号成功!'});
          // 重新加载
          this.closeDialog('refresh');
        }else {
          this.$notify.error({title: '提示信息',message:res.errMsg||'生成临时账号失败!'});
          this.saveLoading = false;
          //this.closeDialog();
        }

    },
    //执行转经销商
    async doTurnDialog(){
        this.saveLoading = true;
        let submitData = Object.assign({},this.value.rowData,this.formData.base,this.formData.empower);
        console.log("submitData:",submitData);
        let res;

        res = await turnDealer(submitData,this.applyId);
        if (res.resultCode === 200) {
          this.$notify.success({title: '提示信息',message:'转经销商成功!'});
          // 重新加载
          this.closeDialog('refresh');
        }else {
          this.$notify.error({title: '提示信息',message:res.errMsg||'转经销商失败!'});
          this.saveLoading = false;
          //this.closeDialog();
        }
	},
	//校验并保存
    async doCompleteSaveDialog(){
      this.saveLoading = true;
	  let submitData = Object.assign({},this.value.rowData,this.formData.base,this.formData.empower);
	  let res;
      //如果传入参数不为空并且为修改
      if(this.value!=null && this.value.type=="edit"){
        res = await updataDealerApply(submitData,this.applyId);
      }else{
        res = await insertDealerApply(submitData);
      }
      if (res.resultCode === 200) {
        this.$notify.success({title: '提示信息',message:'保存成功!'});
        // 重新加载
        this.closeDialog('refresh');
      }else {
        this.$notify.error({title: '提示信息',message:res.errMsg||'保存失败!'});
        this.saveLoading = false;
	  }
    },
    closeDialogTop(){
      this.$confirm('确认关闭窗口吗？您所做的操作将不会被保存！', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
      })
      .then(() => {
        this.closeDialog('closeDialog');
      })
    },
    //取消操作
    closeDialog(type) {
     this.$emit('close', { visible: false,type:type});
    },

  }
};
</script>

<style lang="less" scoped>
</style>
